/**
 * Created with IntelliJ IDEA.
 * User: ajhin
 * Date: 2/25/14
 * Time: 7:58 PM
 * To change this template use File | Settings | File Templates.
 */
package com.societyGames.codeAlong.state.loading
{
import com.societyGames.codeAlong.state.codeExercise.model.ModuleData;
import com.societyGames.codeAlong.state.codeExercise.view.TextDialog;
import com.societyGames.codeAlong.state.exerciseSelect.ExerciseSelectState;
import com.societyGames.codeAlong.user.PersistentUserData;
import com.societyGames.codeAlong.user.UserDataError;
import com.societyGames.flashForms.DialogManager;

/**
 * Shows an error dialog then the mission select.
 */
public class UserDataErrorState extends ExerciseSelectState
{
  public function UserDataErrorState(userData:PersistentUserData, moduleDatas:Vector.<ModuleData>)
  {
    super(userData, moduleDatas);

    var windowName:String = "";
    var description:String;
    switch (userData.userDataError)
    {
      case UserDataError.FLUSH_FAILED:
        windowName = "Saving Progress Disabled";
        description = "<body>To automatically save your mission progress:<br>1) Right click here.<br>2) Click \"Settings...\".<br>3) Click the Folder icon.<br>4) Uncheck \"Never Ask Again\".<br>5) Move the slider to 100kb.</body>";
        break;
      case UserDataError.CORRUPT:
        windowName = "Corrupt Progress";
        description = "<body>Oops! We couldn't read your progress. Don't worry, you can continue where you left off by selecting your last mission.</body>";
        break;
      case UserDataError.INCOMPATIBLE_VERSION:
        windowName = "Incompatible Progress";
        description = "<body>Oops! Your previous progress was made with an older version. Don't worry, you can continue where you left off by selecting your last mission.</body>";
        break;
    }
    var textDialog:TextDialog = new TextDialog(windowName, description);
    DialogManager.instance.showDialog(textDialog)
  }
}
}
